#include<bits/stdc++.h>
#define bh int main
using namespace std;
const int  N=1e5;
int a[2][13]=
{
{0,31,28,31,30,31,30,31,31,30,31,30,31},//平年 
{0,31,29,31,30,31,30,31,31,30,31,30,31}//闰年 
};

void m_day(int * year,int * yearday,int * month,int * day){
    int run=(*year%4==0&&*year%100!=0)||*year%400==0;
    for(int k=1;*yearday>a[run][k];k++){
        *yearday-=a[run][k];
        *month=k;
    }
    *month+=1;
    *day=*yearday;
    }
bh(){
int day,year,month,yearday;
cin>>year>>yearday;
m_day(&year,&yearday,&month,&day);
    if(year<10){
        printf("000%d-",year);
    }
    else if(year<100){
        printf("00%d-",year);
    }
    else if(year<1000){
        printf("0%d-",year);
    }
    else{
        printf("%d-",year);
    }
    
    if(month<10){
        printf("0%d-",month);
    }
    else{
        printf("%d-",month);
    }
    
        if(day<10){
        printf("0%d",day);
    }
    else{
        printf("%d",day);
    }
return 0;
}